#include <bits/stdc++.h>
using namespace std;
/*
input:
3 9 20 -1 -1 15 7 -2
correct output:
3 2
*/
struct TreeNode
{
    int val;
    struct TreeNode *left;
    struct TreeNode *right;
};
// ----------------- 内部裁判实现
TreeNode * BuildTree(vector<int> arr)
{
    int i = 0, n = arr.size();
    queue<TreeNode *> q;
    if(n==0)
        return NULL;
    TreeNode *head = new TreeNode;
    head->val = arr[i];
    q.push(head);
    i++;
    while(i<n&&!q.empty())
    {
        TreeNode *root = q.front();
        q.pop();
        if (i < n && arr[i] != -1)
        {
            TreeNode *newnode = new TreeNode;
            newnode->val = arr[i];
            newnode->left = NULL;
            newnode->right = NULL;
            root->left = newnode;
            q.push(newnode);
        }
        i++;
        if (i < n && arr[i] != -1)
        {
            TreeNode *newnode = new TreeNode;
            newnode->val = arr[i];
            newnode->left = NULL;
            newnode->right = NULL;
            root->right = newnode;
            q.push(newnode);
        }
        i++;
    }
    return head;
}
// -------------- 内部裁判实现


void computeHeightWidth(TreeNode *root)
{
    // root width = 1
    int Maxw = 1, Maxh = 0;
    queue<TreeNode *> q;
    q.push(root);
    while(true)
    {
        int n = q.size();
        // 当前层 无节点了 可跳出
        if(n == 0)
            break;

        // 当前层还有节点
        while (n > 0)
        {
            TreeNode *tmp = q.front();
            q.pop();
            n--;
            if (tmp->left != nullptr)
                q.push(tmp->left);
            if (tmp->right != nullptr)
                q.push(tmp->right);
        }
        Maxh++;
        // 看看下层节点个数
        Maxw = Maxw > q.size() ? Maxw : q.size();
    }
    cout << Maxh << ' ' << Maxw << endl;
}
int main()
{
    freopen("file.in", "r", stdin);
    int ink, h, w;
    vector<int> arr;
    cin >> ink;
    while (ink != -2)
    {
        arr.push_back(ink);
        cin >> ink;
    }
    TreeNode *head = BuildTree(arr);
    computeHeightWidth(head);
    return 0;
}